$(document).ready(function()
{
	/**
	* 产品查询
	*/
	$.initProv("#Supply_Province","#Supply_City");
	var supply_button=$('#Supply_Button');	
	var supply_province=$('#Supply_Province');
	var supply_city=$('#Supply_City');
	var supply_year=$('#Supply_Year');
	var supply_title=$('#Supply_Title');
	supply_button.click(function()
	{		
		if(supply_province.val()=='-1'&&supply_city.val()=='-1'&&supply_year.val()=='-1'&&supply_title.val()=='')
		{
			supply_province.focus();
			return false;		
		}		
		
		var location='http://ancillary.shipinall.cn/exec.php?action=ancillary_supply_list&type=search';
		{
			if(supply_province.val()!=''){
				location=location+'&province='+encodeURI(supply_province.val());
			}	
			if(supply_city.val()!=''){
				location=location+'&city='+encodeURI(supply_city.val());
			}	
			if(supply_year.val()!=''){
				location=location+'&year='+encodeURI(supply_year.val());
			}
			if(supply_title.val()!=''){
				location=location+'&title='+encodeURI(supply_title.val());
			}			
		}
		window.location=location;
		return false;
	});
	
	
	/**
	* 企业查询
	*/
	$.initProv("#Company_Province","#Company_City");
	var company_button=$('#Company_Button');
	var company_province=$('#Company_Province');
	var company_city=$('#Company_City');
	var company_model=$('#Company_Model');
	var company_name=$('#Company_Name');
	company_button.click(function()
	{
		if(company_province.val()=='-1'&&company_city.val()=='-1'&&company_model.val()=='-1'&&company_name.val()=='')
		{
			company_province.focus();
			return false;		
		}		
		
		var location='http://ancillary.shipinall.cn/exec.php?action=ancillary_account_list&type=search';
		{
			if(company_province.val()!=''){
				location=location+'&province='+encodeURI(company_province.val());
			}	
			if(company_city.val()!=''){
				location=location+'&city='+encodeURI(company_city.val());
			}	
			if(company_model.val()!=''){
				location=location+'&model='+encodeURI(company_model.val());
			}
			if(company_name.val()!=''){
				location=location+'&name='+encodeURI(company_name.val());
			}			
		}	
		
		window.location=location;
		return false;
	});
	
	/**
	* 船厂查询
	*/		
	$.initProv("#Shipyard_Province","#Shipyard_City");
	var shipyard_button=$('#Shipyard_Button');
	var shipyard_province=$('#Shipyard_Province');
	var shipyard_city=$('#Shipyard_City');
	var shipyard_category=$('#Shipyard_Category');
	shipyard_button.click(function()
	{		
		if(shipyard_province.val()=='-1'&&shipyard_city.val()=='-1'&&shipyard_category.val()=='-1')
		{
			shipyard_province.focus();
			return false;
		}
		
		var location='/exec.php?action=shipyard_account_list&type=search';
		{
			if(shipyard_province.val()!='-1'){
				location=location+'&province='+encodeURI(shipyard_province.val());
			}		
			
			if(shipyard_city.val()!='-1'){
				location=location+'&city='+encodeURI(shipyard_city.val());
			}		
			
			if(shipyard_category.val()!='-1'){
				location=location+'&category='+encodeURI(shipyard_category.val());
			}					
		}
		
		window.location=location;		
		return false;
	});
	
	
	/**
	* 订单查询
	*/	
	var ordersheet_button=$('#Ordersheet_Button');
	var ordersheet_shipyardName=$('#Ordersheet_ShipyardName');
	var ordersheet_shipownerName=$('#Ordersheet_ShipownerName');
	var ordersheet_shiponwerNationality=$('#Ordersheet_ShiponwerNationality');
	var ordersheet_amount=$('#Ordersheet_Amount');
	var ordersheet_giveDatetime_Year=$('#Ordersheet_GiveDatetime_Year');
	var ordersheet_giveDatetime_Month=$('#Ordersheet_GiveDatetime_Month');
	var ordersheet_datetime_Year=$('#Ordersheet_Datetime_Year');
	var ordersheet_datetime_Month=$('#Ordersheet_Datetime_Month');
	
	ordersheet_button.click(function()
	{
		var isNotWrite=ordersheet_shipyardName.val()==''&&ordersheet_shipownerName.val()=='';
		{
			isNotWrite=isNotWrite&&ordersheet_shiponwerNationality.val()==''&&ordersheet_amount.val()=='';
			isNotWrite=isNotWrite&&ordersheet_giveDatetime_Year.val()=='0'&&ordersheet_giveDatetime_Month.val()=='0';
			isNotWrite=isNotWrite&&ordersheet_datetime_Year.val()=='0'&&ordersheet_datetime_Month.val()=='0';			
		}

		if(isNotWrite)
		{
			ordersheet_shipyardName.focus();
			return false;
		}
		
		var location='/exec.php?action=shipyard_ordersheet&type=search';
		{
			if(ordersheet_shipyardName.val()!=''){
				location=location+'&shipyardname='+encodeURI(ordersheet_shipyardName.val());
			}
			
			if(ordersheet_shipownerName.val()!=''){
				location=location+'&shipownername='+encodeURI(ordersheet_shipownerName.val());
			}
			
			if(ordersheet_shiponwerNationality.val()!=''){
				location=location+'&shiponwernationality='+encodeURI(ordersheet_shiponwerNationality.val());
			}
			
			if(ordersheet_amount.val()!=''){
				location=location+'&amount='+encodeURI(ordersheet_amount.val());
			}
			
			if(ordersheet_giveDatetime_Year.val()!='0'){
				location=location+'&givedatetime_year='+ordersheet_giveDatetime_Year.val();
			}
			
			if(ordersheet_giveDatetime_Month.val()!='0'){
				location=location+'&givedatetime_month='+ordersheet_giveDatetime_Month.val();
			}
			
			if(ordersheet_datetime_Year.val()!='0'){
				location=location+'&datetime_year='+ordersheet_datetime_Year.val();
			}
			
			if(ordersheet_datetime_Month.val()!='0'){
				location=location+'&datetime_month='+ordersheet_datetime_Month.val();
			}			
		}
		
		window.location=location;
		
		return false;
	});

	/**
	* 展会查询
	*/
	var exhibition_button=$('#Exhibition_Button');
	var exhibition_year=$('#Exhibition_Year');
	var exhibition_month=$('#Exhibition_Month');
	var exhibition_place=$('#Exhibition_Place');	

	exhibition_button.click(function()
	{
		if(exhibition_year.val().replace(/\s/g,'')==''&&exhibition_month.val().replace(/\s/g,'')==''&&exhibition_place.val().replace(/\s/g,'')=='')
		{
			exhibition_year.focus();
			return false;			
		}
		
		var location='http://expo.shipinall.cn/exec.php?action=exhibition_infos_list&type=search';
		
		if(exhibition_year.val().replace(/\s/g,'')!=''){
			location=location+'&year='+encodeURI(exhibition_year.val());
		}
		
		if(exhibition_month.val().replace(/\s/g,'')!=''){
			location=location+'&month='+encodeURI(exhibition_month.val());
		}
		
		if(exhibition_place.val().replace(/\s/g,'')!=''){
			location=location+'&place='+encodeURI(exhibition_place.val());
		}		
		
		window.location=location;
		
		return false;
	});	
	
	/**
	* 资讯查询
	*/
	var news_button=$('#News_Button');
	var news_keywords=$('#News_Keywords');	
	
	news_button.click(function()
	{
		if(news_keywords.val().replace(/\s/g,'')=='')
		{
			news_keywords.val('');
			news_keywords.focus();
			return false;			
		}		
		window.location='http://news.shipinall.cn/exec.php?action=news_list&type=search&keywords='+encodeURI(news_keywords.val());		
		return false;						   
	});
});